<template>
  <div class="myBox">
    <div class="L"><img :src="LoginAuth.avatar_cdn" /></div>
    <div class="C">
      <div class="tit" v-if="LoginAuth.nickname">{{ LoginAuth.nickname }}</div>
      <div class="tit" v-else>未设置昵称</div>
      <div class="sub">{{ LoginAuth.mobile_text }}</div>
    </div>
    <!-- <div class="R"><img src="/assets/images/go.png" /></div> -->
  </div>
  <div class="clear"></div>
  <div class="allkbox"></div>
  <div class="myboxcon" @click="onProfile">
    <p>基本资料</p>
    <img src="/assets/images/go.png" />
  </div>

  <!-- 如果该用户的邮箱为空的时候，才显示邮箱认证 -->
  <div v-if="LoginAuth.email == 0">
    <div class="myboxcon" @click="onEmail">
      <p>邮箱认证</p>
      <img src="/assets/images/go.png" />
    </div>
  </div>

  <div class="myboxcon" @click="this.$router.push('/business/address/index')">
    <p>我的收货地址</p>
    <img src="/assets/images/go.png" />
  </div>
  <div class="myboxcon" @click="this.$router.push('/business/collection/index')">
    <p>我的收藏</p>
    <img src="/assets/images/go.png" />
  </div>
  <div class="myboxcon" @click="onOrder">
    <p>我的订单</p>
    <img src="/assets/images/go.png" />
  </div>
  <div class="myboxcon" @click="onShoppingList">
    <p>消费记录</p>
    <img src="/assets/images/go.png" />
  </div>
  <div class="myboxcon" @click="onCharge">
    <p>充值</p>
    <img src="/assets/images/go.png" />
  </div>
  <div class="myboxcon" @click="logout">
    <p>注销</p>
    <img src="/assets/images/go.png" />
  </div>

  <div class="clear"></div>
  <div class="h54"></div>
  <div class="clear"></div>

  <Tab />
</template>
<script>
  import Tab from '@/components/common/Tab.vue'
  import { showConfirmDialog, showNotify } from 'vant'
  export default {
    components: {
      Tab,
    },
    data() {
      return {
        LoginAuth: {},
      }
    },
    created() {
      this.LoginAuth = this.$cookies.get('LoginAuth') ? this.$cookies.get('LoginAuth') : {}
      //  console.log(this.$cookies)
    },
    methods: {
      onProfile() {
        this.$router.push('/business/base/profile')
      },
      onEmail() {
        this.$router.push('/business/base/email')
      },
      onOrder() {
        this.$router.push('/order/order/index')
      },
      onShoppingList() {
        this.$router.push('/business/shoppingList/index')
      },
      onCharge() {
        this.$router.push('/business/charge/charge')
      },
      async logout() {
        showConfirmDialog({
          title: '确认注销登录吗？',
        })
          .then(() => {
            // on confirm
            // 直接删除cookies
            this.$cookies.remove('LoginAuth')
            showNotify({
              type: 'primary',
              message: '退出登录成功',
              duration: 1500,
              onClose: () => {
                this.$router.push('/business/base/login')
              },
            })
          })
          .catch(() => {
            // on cancel
          })
      },
    },
  }
</script>
